﻿<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/12/13
  Time: 16:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    request.setAttribute("path", path);
%>
<meta charset="utf-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport"
      content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta content="telephone=no" name="format-detection"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<link rel="stylesheet" href=""/>
<head>
    <title>商家注册</title>
    <style>
        body {
            font-size: 62.5%;
            font-family: "Microsoft YaHei", Arial;
            overflow-x: hidden;
            overflow-y: auto;
            padding: 0px;
            margin: 0px;
        }

        .viewport {
            max-width: 640px;
            min-width: 300px;
            margin: 0 auto;
        }

        .Form {
            margin: 20px auto;
            width: 90%;
        }

        .Form form input {
            border-radius: 20px;
            width: 95%;
            padding-left: 5%;
            border: 1.5px solid #FF6D13;
            height: 45px;

        }

        #btnRegister {
            border-radius: 20px;
            width: 95%;
            padding-left: 5%;
            border: 1.5px solid #FF6D13;
            height: 40px;
            margin-bottom: 10px;
        }

        #phone {
            padding-left: 14%;
            width: 94%;
        }

        #btnRegister {
            border: 0px;
            background-color: #FF6D13;
            border-radius: 20px;
            color: white;
        }

        #download {
            border: 0px;
            background-color: #FF6D13;
            border-radius: 20px;
            color: white;
        }

        #checkbox {
            width: 20px;
            height: 20px;
            background-color: #ffffff;
            border: solid 1px #dddddd;
            -webkit-border-radius: 50%;
            border-radius: 50%;
            font-size: 0.8rem;
            margin: 0;
            padding: 0;
            position: relative;
            display: inline-block;
            vertical-align: top;
            cursor: default;
            -webkit-appearance: none;
            -webkit-user-select: none;
            user-select: none;
            -webkit-transition: background-color ease 0.1s;
            transition: background-color ease 0.1s;
        }

        #checkbox:checked {
            background: #FF6D13;
        }

        #checkbox:checked::after {
            content: '';
            top: 2px;
            left: 2px;
            position: absolute;
            background: transparent;
            border: #fff solid 2px;
            border-top: none;
            border-right: none;
            height: 6px;
            width: 10px;
            -moz-transform: rotate(-45deg);
            -ms-transform: rotate(-45deg);
            -webkit-transform: rotate(-45deg);
            transform: rotate(-45deg);
        }

        label {
            z-index: 1;
            position: relative;
            left: 10px;
            top: 29px;
        }

        #get_verification_code {
            line-height: 28px;
            height: 28px;
            text-align: center;
            width: 33%;
            background-color: #ff6d13;
            border-radius: 20px;
            color: white;
            z-index: 1;
            float: right;
            position: relative;
            top: -36px;
            right: 26px;
            cursor: pointer;
        }

        span {

        }

        #password {
            position: relative;
            top: -20px;
        }
    </style>
</head>
<body>
<div class="top"><img width="100%" src="${path}/static/images/top.jpg"/></div>
<div class="Form">
    <form id="registerForm" action="" method="post">
        <input type="hidden" id="userId" name="userId" value="${userId}"/>
        <div>
            <label for="phone" style="font-size:13px ;color: grey;">+86|</label>
            <input id="phone" name="phone" type="text" placeholder="请输入手机号"/><br><br>
        </div>
        <div>
            <input id="verification_code" name="verification_code" type="text" placeholder="请输入验证码"/>
            <lable id="get_verification_code" name="get_verification_code" type="button" value="">获取验证码</lable>
        </div>

        <input id="password" name="password" type="password" placeholder="请设置您的密码"/>

        <div>
            <input id="checkbox" name="checkbox"
                   type="checkbox"/><span>&nbsp;&nbsp;我已阅读并同意<a
                href="http://www.taoshunda.com:80/taoshundabussinter/webview/userAgreement">《淘瞬达商家协议》</a>和<a
                href="http://www.taoshunda.com:80/taoshundabussinter/webview/companyPrivacy">《淘瞬达隐私政策》</a></span>
        </div>

        <br>
        <button id="btnRegister" name="btn" type="button" value="">注 册</button>
        <br>
        <br>

        <%--<input id="download" name="download" type="button" value="下 载 app"/><br><br>--%>
    </form>
</div>
<div class="footer">
    <div style="background: #FF6D13;line-height:50px;text-align: center;display: inline-block;bottom: 0;width: 100%;font-size: 16px; margin-top: 50px">
        <button style="width: 100%; line-height:50px;background: #FF6D13; border: 0px;" id="btn"
                location="
    'http://www.taoshunda.com/setup/business.html'
    "><a
                href="http://www.taoshunda.com/setup/business.html" id="link"
                style="color: #ffffff;">点击下载淘瞬达app，淘您所爱 一瞬即达</a>
        </button>
    </div>
</div>
</body>
<script src="${path}/static/js/jquery-1.11.3.min.js"></script>
<script>
    var second = 60;
    document.getElementById("btn").onclick = function () {
        document.getElementById("link").click();
    }
    $("#get_verification_code").click(function () {
        $("#get_verification_code").attr("disabled", "true");
        $.ajax({
            url: "../web/businessRegister/getRegisterMsg",
            type: "post",
            data: {mobile: $("#phone").val()},
            success: function (data) {
                if (data) {
                    $("#get_verification_code").html("剩余" + second + "秒");
                    setInterval(function () {
                        if (second <= 0) {
                            $("#get_verification_code").html("获取验证码");
                            second = 60;
                            $("#get_verification_code").attr("disabled", "false");
                        } else {
                            second = second - 1;
                            $("#get_verification_code").html("剩余" + second + "秒");
                        }
                    }, 1000)
                } else {
                    alert("手机号有误或者手机号超过次数")
                }
            },
            error: function (e) {
                console.log(e);
            }
        });
    });

    $("#btnRegister").click(function () {
        if ($("input[type='checkbox']").is(':checked')) {
            $("#btnRegister").attr("disabled", "true")
            var formData = new FormData(document.getElementById("registerForm"));
            $.ajax({
                url: "../web/businessRegister/businessRegister",
                type: "post",
                data: formData,
                processData: false,
                contentType: false,
                success: function (data) {
                    console.log(data)
                    if (data) {
                        alert("注册成功");
                        window.location.href = "http://www.taoshunda.com/setup/business.html";
                    } else {
                        console.log("注册失败");
                    }
                }
            });
        } else {
            alert("请仔细阅读协议并确认！");
        }

    });

</script>
